import 'package:flutter/material.dart';
import 'package:hm_show_flutter/style/style.dart';
import 'package:hm_show_flutter/utils/toast_util.dart';

class SearchView extends StatelessWidget {
  final bool leftVisible;
  final bool enableSearch;

  SearchView({this.leftVisible = true, this.enableSearch = false});

  @override
  Widget build(BuildContext context) {
    final search = ConstrainedBox(
      constraints: BoxConstraints(maxHeight: 35),
      child: TextField(
          autofocus: false,
          onTap: () {
            if (!enableSearch) {
              ToastUtil.showToast("搜索");
              FocusScope.of(context).requestFocus(new FocusNode());
            }
          },
          scrollPadding: EdgeInsets.only(left: 0),
          decoration: InputDecoration(
            contentPadding: const EdgeInsets.symmetric(vertical: 2.0),
            hintText: '请输入搜索内容',
            hintStyle: TextStyle(fontSize: 14),
            prefixIcon: Icon(
              Icons.search,
              color: AppColors.mainColor,
            ),
            border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(32),
                borderSide: BorderSide.none),
            filled: true,
            fillColor: Colors.white,
          )),
    );

    return search;
  }
}
